package com.zoroki.student_score_system.controller;



import com.zoroki.student_score_system.domain.College;
import com.zoroki.student_score_system.service.CollegeService;
import com.zoroki.student_score_system.utils.Msg;
import com.zoroki.student_score_system.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/college")
public class CollegeController {
    @Autowired
    CollegeService collegeService;


    @GetMapping("/getAllCollege")
    public @ResponseBody Result<List<College>> getAllCollege() {
        return new Result<List<College>>(0,collegeService.getAllCollege(), Msg.SUCCESS);
    }

    @GetMapping("/getCollegeById")
    public @ResponseBody Result<College> getCollegeById(int id) {
        return new Result<College>(0,collegeService.getCollegeById(id), Msg.SUCCESS);
    }


    @PostMapping("/addCollege")
    public @ResponseBody Result<Boolean> addCollege(@RequestBody College college) {
        return new Result<Boolean>(0,collegeService.addCollege(college), Msg.SUCCESS);
    }

    @PostMapping("/updateCollege")
    public @ResponseBody Result<Boolean> updateCollege(@RequestBody College college) {
        return new Result<Boolean>(0,collegeService.updateCollege(college), Msg.SUCCESS);
    }

    @PostMapping("/deleteCollege")
    public @ResponseBody Result<Boolean> deleteCollege(int id) {
        return new Result<Boolean>(0,collegeService.deleteCollege(id), Msg.SUCCESS);
    }

}
